<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>对象</title>
</head>
<body>
    
</body>
</html>
<script>
    const mrDeng = {
        name : "zhi",
        age :"23",
        sex : "mamle",
        health : 100,
        smoke : function () {
            console.log("I am smoking");
            mrDeng.health --;
        },
        drink : function (){
            console.log("I am drink");
            mrDeng.health ++;
        }
    }
    mrDeng.wifi = "xiaowang"; //增
    mrDeng.sex = "female"     //改
    delete mrDeng.sex;    //删
    console.log(mrDeng.sex); //查


    const deng = {
        preparewife : "xioawang",
        name : "laodeng",
        sex : "xiaoliu",
        wifi : "",
        divorce : function () {
            delete this.wifi
            this.wifi = this.preparewife;
            this.gf = this.prepareWife;
        },
        getMarried : function (){
            this.wifi = this.gf;
        },
        changPrepareWife : function (someone){
            this.prepareWife = someone;
        }
    } 

    // 对象的创建方法
    /*
    1 var obj = {}   plainObject 对象字面量/对象直接量
    2. 构造函数
        系统自带的构造函数 Object()
        自定义  

        大驼峰式命名规则
     */
     var obj = new Object();

     function Car (color) {
         this.color = color ;
         this.name = 'BMW';
         this.height = '1400';
         this.weight = '1000';
         this.health = 100;
         this.run = function (){
             this.health --;
         }
     }
     const car = new Car();
     const car1 = new Car();

     function Student(name,age,sex) {
         this.name = name;
         this.age = age;
         this.sex = sex;
         this.grade = 2017;
       }
       var student = new Student('张三', 18, 'male');

    //    构造函数内部原理
    // 1.在函数体最前面隐士的加上 this = {}
    // 2.执行 this.xxx = xxx;
    // 隐士的返回this


    function Person (name, height){
        var that = {};
        that.name = name;
        that.height = height;
        return that;
    }
    let person = Person('xiaowang', 180);
    let person1 = Person('xiaozhang', 175);

    let str = 'abc'
    str += 1;
    let test = typeof(str)
    if (test.length == 6) {
        test.sign = 'aaa'
    }
    console.log(test.sign);
</script>